﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace EShop.Model
{
    public class BaseInfo
    {
        /// <summary>
        /// 循环取出类中所有数据，为出错写日志记录数据
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            Type type = this.GetType();
            //获取属性集合
            PropertyInfo[] proInfo = type.GetProperties();
            StringBuilder itemValues=new StringBuilder();

            foreach (PropertyInfo item in proInfo)
            {
                itemValues.AppendFormat("{0} = {1}\r\n", item.Name, item.GetValue(this, null));
            }

            return itemValues.ToString();
        }
    }
}
